#ifndef     __BLE_TASK_H
#define     __BLE_TASK_H

#include "../rtos/thread.h"
#include "../utils/object.h"

namespace task {

class BLETask : public rtos::Thread<BLETask, 1024, osPriorityHigh2> {

public:
    static constexpr uint32_t RecvBuffSize = 256;

    void run();

private:
    uint32_t pkg_exec(const uint8_t *buf, uint32_t len);
    void post(const uint8_t *buf, uint32_t len);

private:
    uint8_t m_recv_buf[RecvBuffSize];
    bool m_head_flag = false;
    uint16_t m_pkg_len = 0;
    uint16_t m_pkg_index = 0;
};

inline utils::object_t<BLETask> bleTask;

}

#endif
